# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 2.创建浏览器驱动对象
# Firefox浏览器:
# driver = webdriver.Firefox()
# Chrome浏览器:
path = r"D:\Programs\Python\Python313\chromedriver.exe"
ser = Service(executable_path = path)
driver = webdriver.Chrome(service = ser)
# 使用Edge浏览器,不需要安装驱动
# driver = webdriver.Edge ()
# 3.打开Web页面
driver.get(f"http://121.43.169.97:8848/pageA.html")
# 最大化窗口
driver.maximize_window()
time.sleep(3)
# 设置窗口宽高
driver.set_window_size(500, 700)
time.sleep(3)
# 设置窗口位置
driver.set_window_position(0, 500)
time.sleep(3)
# 点击超链接
driver.find_element(by=By.LINK_TEXT, value="百度").click()
time.sleep(3)
# 返回上一页
driver.back()
time.sleep(3)
# 前进
driver.forward()
time.sleep(3)
# 刷新
driver.refresh()


# 4.暂停
time.sleep(3)
# 5.关闭浏览器驱动对象
driver.quit()